export default {
  watch: {
    $route: {
      handler(next) {
        if (next.query.tab) {
          this.activeTab = next.query.tab;
          if (next.query.newView) { // 针对游戏报表直接跳到tab2的情况
            this.$router.replace({ path: this.$route.path, query: { ...this.$route.query, tab: 'two', newView: false } });
          }
        } else {
          this.$router.replace({ path: this.$route.path, query: { ...this.$route.query, tab: 'one' } });
        }
      },
      immediate: true,
    },
    activeTab: {
      handler(current) {
        if (!this.$route.query.tab || this.$route.query.tab !== current) {
          this.$router.replace({ path: this.$route.path, query: { ...this.$route.query, tab: current } });
        }
      },
      immediate: true,
    },
  },
  methods: {
    changeTab(tabs) {
      this.activeTab = tabs.name;
    },
  },
};
